<template>
  <div>
    <v-top></v-top>
    <div class="int">
      <input type="text" placeholder="笔记本" v-model="user.name" @change="search" />
    </div>
    <div v-if="arr.length==0">暂无数据</div>
    <router-link  :to="'/detail/'+item.id"  v-for="item in arr" :key="item.id">
      <div  class="box">
      <div class="lef">
        <img :src="$pre+item.img" alt />
      </div>
      <div class="rig">
        <h3>{{item.goodsname}}</h3>
        <h3>{{item.price}}</h3>
        <h3>{{item.market_price+"评论"}}</h3>
      </div>
    </div>
    </router-link>
    
    
  </div>
</template>

<script>

import { reqSearch } from "../../http/api";
export default {
  data() {
    return {
      user: { name: "" },
      arr:[]
    };
  },
  methods: {
    search() {
      if(this.user.name===""){
        this.arr=[]
        return;
      }
      reqSearch({ keywords: this.user.name }).then((res) => {
        console.log(res);
        this.arr=res.data.list?res.data.list:[]
      });
    },
  },
};
</script>

<style scoped>
.int {
  background: orangered;
  height: 1rem;
  position: relative;
  padding-top: 0.5rem;
}
input {
  border: 2px solid orangered;
  width: 80%;
  height: 0.7rem;
  font-size: 0.3rem;
  margin: 0 auto;
  display: block;
  border-radius: 0.2rem;
  background: #fff;
}
.box {
  margin: 0 auto;
  padding-top: 0.2rem;
  width: 90%;
  height: 2rem;
  border-bottom: 1px solid #ccc;
}
.lef {
  width: 1.5rem;
  position: absolute;
  margin-left: 0.2rem;
}
img {
  width: 1.5rem;
  height: 1.5rem;
}
.rig {
  padding-left: 2rem;
  width: 60%;
}
</style>